package com.agent.auth.controller;

import com.agent.auth.dto.AdminLoginRequest;
import com.agent.auth.service.AdminAuthService;
import com.agent.common.result.ApiResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 管理员登录
 */
@RestController
@RequestMapping("/admin/auth")
@RequiredArgsConstructor
public class AdminAuthController {
    private final AdminAuthService adminAuthService;

    /**
     * 管理员用户登录
     *
     * @param request 请求信息
     * @return token
     */
    @PostMapping("/login")
    public ApiResponse<String> adminLogin(@RequestBody @Valid AdminLoginRequest request) {
        String token = adminAuthService.adminLogin(request);
        return ApiResponse.success(token);
    }
}